<template>
  <div>
    <h1 class="title">
      专家和网友诊断
    </h1>
    <div>
      <div class="header">
        <el-radio-group @input="queryList" v-model="query.state">
          <el-radio label="待鉴定"></el-radio>
          <!-- <el-radio label="已鉴定"></el-radio> -->
        </el-radio-group>
        <div class="btns">
          <el-button size="medium" icon="el-icon-caret-right" type="success" round
            @click="consultation">我要咨询</el-button>
          <el-button size="medium" icon="el-icon-caret-right" type="primary" round @click="pushAnswer">我要解答</el-button>
          <!-- <el-button size="medium" icon="el-icon-caret-right" type="primary" round @click="pushAnswer">查看已解答</el-button> -->
        </div>
      </div>
      <!-- 走马灯 -->
      <div>
        <el-carousel :interval="4000" type="card" height="45vh">
          <!-- <el-carousel-item v-for="(item, index) in dataList" :key="index">
            <img class="caroImg" src="https://img1.baidu.com/it/u=505459533,3553123496&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1671210000&t=0c4bbc13878d49a9a60e1184dac1f947" alt=""
              @click="isbox(item)">
            <div>标题：{{ item.title }}</div>
            <div>备注：{{ item.remarks }}</div>
          </el-carousel-item> -->
          <el-carousel-item>
            <img class="caroImg" src="https://img1.baidu.com/it/u=505459533,3553123496&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1671210000&t=0c4bbc13878d49a9a60e1184dac1f947" alt=""
              @click="isbox">
            <div>标题： 这是什么虫子啊</div>
            <div>备注： 大家帮我看一下这是什么虫子 </div>
          </el-carousel-item>
          <el-carousel-item>
            <img class="caroImg" src="https://img0.baidu.com/it/u=1674949878,1465476118&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1671210000&t=8e8407dd0300cc2b6dafcb13d126b14f" alt=""
              @click="isbox">
              <div>标题： 这是什么虫子啊</div>
            <div>备注： 大家帮我看一下这是什么虫子 </div>
          </el-carousel-item>
          <el-carousel-item>
            <img class="caroImg" src="https://img1.baidu.com/it/u=1990963916,2848259677&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1671210000&t=8f8fe49d4cf875197628a29824d1e302" alt=""
              @click="isbox">
              <div>标题： 这是什么虫子啊</div>
            <div>备注： 大家帮我看一下这是什么虫子 </div>
          </el-carousel-item>
          <el-carousel-item>
            <img class="caroImg" src="https://img1.baidu.com/it/u=2179044939,1284043468&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1671210000&t=73bf4d40840f29944593c46652ed9275" alt=""
              @click="isbox">
              <div>标题： 这是什么虫子啊</div>
            <div>备注： 大家帮我看一下这是什么虫子 </div>
          </el-carousel-item>
        </el-carousel>

      </div>
    </div>
    <!-- 回复 -->
    <div class="reply">
      <div>2022年3月16日 16:00 来自大同的网友找专家鉴定 0 人回复</div>
      <div>2022年3月16日 16:00 来自大同的网友找专家鉴定 2 人回复</div>
      <div>2022年3月16日 16:00 来自大同的网友找专家鉴定 10人回复</div>
      <div>2022年3月16日 16:00 来自大同的网友找专家鉴定 21人回复</div>
      <div>2022年3月16日 16:00 来自大同的网友找专家鉴定 40人回复</div>
      <!-- <div>--- 查看更多列表 ---</div> -->
    </div>
    <!-- 我要咨询对话框 -->
    <el-dialog title="问题咨询" :visible.sync="dialogVisible" width="40%">
      <el-form :model="consultationFrom" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="标题" prop="title">
          <el-input v-model="consultationFrom.title"></el-input>
        </el-form-item>
        <el-form-item label="区域" prop="address">
          <el-input v-model="consultationFrom.address"></el-input>
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input v-model="consultationFrom.remarks"></el-input>
        </el-form-item>
        <el-form-item label="上传图片：">
          <!-- <div class="isImg">+</div> -->
          <upload-img v-model="img"></upload-img>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmTheConsultation">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 解答对话框 -->
    <el-dialog title="问题描述" :visible.sync="answerVisible" width="40%">
      <div>
        <div class="dil-txt">问题名称：<span>大家帮我看一下这是什么虫害</span></div>
        <div class="dil-txt2">描述：<span>我今天中午的时候家旁边遇到一个红色的蚂蚁，咬人很疼！</span></div>
        <div>图片：
          <img class="dilImg"
            src="https://img0.baidu.com/it/u=495321769,3560736975&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1671210000&t=d3c39f24af444cb6ba909c7a25610073"
            alt="">
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="answerVisible = false">取 消</el-button>
        <el-button type="primary" @click="answerVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import $http from '@/main.js'
import uploadImg from '../../components/uploadImg.vue'
export default {
  components: { uploadImg },
  data () {
    return {
      img: '',
      query: {
        state: '待鉴定'
      },
      state: 0,
      dataList: [],
      // 我要咨询对话框
      dialogVisible: false,
      // 解答对话框
      answerVisible: false,
      // 咨询数据
      consultationFrom: {
        identify_id: 1,
        // 标题
        title: '',
        // 备注
        remarks: '',
        // 区域
        address: '',
        // 图片
        image: ''
      },
      rules: {
        title: [
          { required: true, message: '请输入', trigger: 'blur' }
        ],
        address: [
          { required: true, message: '请输入', trigger: 'blur' }
        ],
        remarks: [
          { required: true, message: '请输入', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    queryList () {
      if (this.query.state === '待鉴定') {
        this.state = 0
      } else {
        this.state = 5
      }
      this.getdata()
    },
    async getdata () {
      const { data: res } = await $http.post('index/diagnose/getQuestions', { state: this.state })
      this.dataList = res.data
      console.log(this.dataList)
    },
    // 咨询按钮
    consultation () {
      this.dialogVisible = true
    },
    // 确定咨询
    confirmTheConsultation () {
      this.$refs.ruleForm.validate(async (valid) => {
        if (!valid) return false
        await $http.post('/diagnose/consult', this.consultationFrom)
        this.$message.success('上传成功')
        this.getdata()
        this.dialogVisible = false
      })
    },
    // 跳转解答界面
    pushAnswer () {
      this.$router.push('/Answer')
    },
    // 解答
    async isbox (item) {
      console.log(item.id)
      this.answerVisible = true
      const { data: res } = await $http.post('index/diagnose/getQuestion', item.id)
      console.log(res)
    }
  },
  created () {
    this.getdata()
  }
}
</script>

<style lang="less" scoped>
.title {
  text-align: center;
  margin-top: 2.5vh;
  font-weight: 900;
}

.el-radio-group {
  font-size: 72px;

  :deep(.el-radio__label) {
    font-size: 24px;

  }
}

:deep(.el-radio__inner) {
  width: 24px !important;
  height: 24px !important;
}

.header {
  width: 60vh;
  height: 100px;
  margin: auto;
  display: flex;
  justify-content: space-evenly;

  .btns {
    margin-top: 5.5%;
  }
}

// 走马灯
.el-carousel__item h3 {
  // color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 40vh;
  margin: 0;
  width: 90%;
}

.el-carousel__item:nth-child(2n) {
  background-color: #fff;
  box-shadow: 0 8px 30px #ddd;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #fff;
  box-shadow: 0 8px 30px #ddd;
}

.caroImg {
  width: 100%;
  height: 80%;
}

.footer-box {
  display: flex !important;
  justify-content: space-between !important;
}

.isbox2 {
  .box1 {
    span {
      font-size: 22px;
      color: #003388;
      padding: 12px 0px;
    }
  }

  .box2 {
    span {
      color: #883300;
      font-size: 18px;
    }
  }

  .box3 {
    span {
      color: #883300;
      font-size: 18px;
    }
  }

  .box4 {
    span {
      color: #883300;
      font-size: 18px;
    }
  }

  .box5 {
    span {
      color: #883300;
      font-size: 18px;
    }
  }
}

:deep(.el-carousel__arrow) {
  background-color: black;
}

.reply {
  text-align: center;
  font-weight: 400;

  div {
    margin-top: 14px;
    color: black;
  }
}

.dilImg {
  width: 50%;
}

.dil-txt {
  font-size: 20px;
  margin-bottom: 2vh;
}

.dil-txt2 {
  font-size: 18px;
  margin-bottom: 2vh;
}

.isImg {
  width: 100px;
  height: 100px;
  border: 1px dashed #d9d9d9;
  text-align: center;
  line-height: 100px;
}
</style>
